package com.bdqn.t320.ch03mybatis.controller;

import com.bdqn.t320.ch03mybatis.entity.User;
import com.bdqn.t320.ch03mybatis.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.naming.Name;

@RestController
public class UserController {

    @Resource
    UserService userService;

    @RequestMapping("/add")
    public Object add(@RequestParam(name = "usrName") String usrName1,
                      @RequestParam(name = "usrPassword") String usrPassword1,
                      @RequestParam(name = "usrRoleId") Long usrRoleId1,
                      @RequestParam(name = "usrFlag") Integer usrFlag1) {
        return userService.save(new User(usrName1, usrPassword1, usrRoleId1, usrFlag1));
    }

    @GetMapping("/addrest/{usrName}/{usrPassword}/{usrRoleId}/{usrFlag}")
    public Object addrest(@PathVariable(name = "usrName") String usrName1,
                      @PathVariable(name = "usrPassword") String usrPassword1,
                      @PathVariable(name = "usrRoleId") Long usrRoleId1,
                      @PathVariable(name = "usrFlag") Integer usrFlag1) {
        return userService.save(new User(usrName1, usrPassword1, usrRoleId1, usrFlag1));
    }

}
